layui.use(['table', 'admin', 'ax'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;

    /**
     * 运输费用表管理
     */
    var TransportCost = {
        tableId: "transportCostTable"
    };

    /**
     * 初始化表格的列
     */
    TransportCost.initColumn = function () {
        return [[
            {field: 'id', hide: true, title: '主键id'},
            {field: 'priceName', title: '费用名称', style:'font-weight: 600;'},
            {field: 'priceMode', title: '计价方式', style:'font-weight: 600;'},
            {field: 'price', sort: true, title: '单价', totalRowText: '合计：', style:'font-weight: 600;'},
            {field: 'nums', sort: true, title: '总量', totalRow: true, style:'font-weight: 600;'},
            {field: 'money', sort: true, title: '金额', totalRow: true, style:'font-weight: 600;'},
            {field: 'v3', sort: true, title: '起步点数', totalRow: true, style:'font-weight: 600;'},
            {field: 'v4', sort: true, title: '超点费用', totalRow: true, style:'font-weight: 600;'},
            {field: 'lineName', title: '线路名称', style:'font-weight: 600;'},
        ]];
    };

    /**
     * 点击查询按钮
     */
    TransportCost.search = function () {
        var queryData = {};
        queryData['condition'] = $("#condition").val();
        table.reload(TransportCost.tableId, {
            where: queryData, page: {curr: 1},
             done:function () {
            }
        });
    };

    // 渲染表格
    var tableResult = table.render({
        elem: '#' + TransportCost.tableId,
        url: Feng.ctxPath + '/transportCost/list?dispatchNumber=' + Feng.getUrlParam("dispatchNumber"),
        page: false,
        limit: 1000,
        height: "full-60",
        totalRow: true,
        toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
        cellMinWidth: 100,
        cols: TransportCost.initColumn()
    });

    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        TransportCost.search();
    });
});
